//
//  DDUploadAddressBook.m
//  MyClouds
//
//  Created by sarah doo on 13-8-11.
//  Copyright (c) 2013年 sarah doo. All rights reserved.
//

#import "DDUploadAddressBook.h"

@implementation DDUploadAddressBook


- (id)initWithData:(NSData *)data {
    self = [super initWithData:data];
    return self;
}


-(id)initWithFileSize:(long)fileSize{
    self = [super init];
    
    NSData* fileSizeData = [[NSData alloc]initWithBytes:&fileSize length:LONG_SIZE];
    NSRange range;
    range.location = HEADER_LENGTH;
    range.length = LONG_SIZE;
    [entity replaceBytesInRange:range withBytes:fileSizeData];
    [fileSizeData release];
    [self setCmd:CloudCmd_UploadAddressBook];
    [self setLength:[entity length]];
    int crc = [self crcs:entity withLength:[entity length]];
    [self setCrc:crc];
    return self;
}

- (long)getFileSize{
    NSRange range;
    range.location = HEADER_LENGTH;
    range.length = LONG_SIZE;
    
    NSData* fileSizeData = [entity subdataWithRange:range];
    long fileSize = [self dataToLong:fileSizeData];
    return fileSize;
}

@end
